<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>健康指标列表</title>
    <style>
        /* 保持原有样式不变 */
        table { width: 100%; border-collapse: collapse; }
        th, td { padding: 12px; border: 1px solid #ddd; }
        th { background-color: #4CAF50; color: white; }
        tr:nth-child(even) { background-color: #f2f2f2; }
        .action-buttons { display: flex; gap: 10px; }
        .btn {
            padding: 6px 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
        }
        .btn:hover { background-color: #45a049; }
        a {
            color: #4CAF50;
            text-decoration: none;
            margin-right: 10px;
        }
    </style>
</head>
<body>
<h2>健康指标记录表</h2>
<!-- 添加按钮 -->
<a href="<%=request.getContextPath()%>/healthmetrics/add" class="a">添加记录</a>

<table>
    <tr>
        <th>ID</th>
        <th>用户ID</th>
        <th>指标类型</th>
        <th>数值</th>
        <th>单位</th>
        <th>记录时间</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${healthmetrics}" var="metrics">
        <tr>
            <td>${metrics.metricsid}</td>
            <td>${metrics.userid}</td>
            <td>
                <c:choose>
                    <c:when test="${metrics.metricstype == 'weight'}">体重</c:when>
                    <c:when test="${metrics.metricstype == 'bloodpressure'}">血压</c:when>
                    <c:otherwise>${metrics.metricstype}</c:otherwise>
                </c:choose>
            </td>
            <td>${metrics.value}</td>
            <td>${metrics.unit}</td>
            <td>${metrics.createtime}</td>
            <td class="action-buttons">
                <a href="${pageContext.request.contextPath}/healthmetrics/edit/${metrics.metricsid}" class="btn">编辑</a>
                <a href="${pageContext.request.contextPath}/healthmetrics/delete/${metrics.metricsid}"
                   class="btn"
                   onclick="return confirm('确定删除吗？')">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>